package com.epoint.jwt.rest;

import com.epoint.jwt.untils.JWTUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestRest {

    @GetMapping("/getToken")
    public String getToken(String username, String password){
        // 校验密码
        if(username.equals("jkh") && password.equals("11111")){
            Map<String, String> map = new HashMap<>();
            map.put("name", "纪宽豪");
            map.put("id", "1");
            String token = JWTUtils.getToken(map);
            return token;
        }
        return "账号密码错误!";
    }

    @PostMapping("/test")
    public String test(){
        return "测试通过";
    }

}
